﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DAL;
using DTO;
using WEBSITE_BANDEAL.App_Code;

namespace WEBSITE_BANDEAL.Admin
{
    public partial class Admin : System.Web.UI.MasterPage
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {            
            lit_date.Text = AddIn.GetDay(DateTime.Now.ToString("ddd")) + ", " + DateTime.Now.ToString("dd/MM/yyyy");
            if (Session["OK"] == null && (string)Session["OK"] != "OK")
            {
                BO_DEM dem = new BO_DEM();
                dem.IP = Request.ServerVariables["REMOTE_ADDR"];
                dem.Link = Request.RawUrl.ToString();
                dem.Thoigian = DateTime.Now;
                dem.Trinhduyet = Request.Browser.Browser.ToString();
                BO_DEMBUS.Insert(dem);
                Session["OK"] = "OK";
            }
            if (Request.Url.ToString().Contains("Login.aspx") == false && Session["UserName"] == null)
                Response.Redirect("~/Admin/Login.aspx");
            if ((Session["UserName"] != null && Session["Ma"] != null))
            {
                int ma = int.Parse(Session["Ma"].ToString());
                ADMIN ad = ADMINBUS.GetByID(ma);
                lit_HoTen.Text = ad.HoTen;
                lit_Email.Text = ad.Mail;
                lit_User.Text = ad.Username;

            }
        }
    }
}